<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.14.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>DM-CtrlH7-BF-DevProgram: C:/Users/ASUS/Desktop/dm-ctrlH7-balance-9025test/modules/motor/DJImotor/dji_motor.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="50x5.png"/></td>
  <td id="projectalign">
   <div id="projectname">DM-CtrlH7-BF-DevProgram<span id="projectnumber">&#160;beta 0.1</span>
   </div>
   <div id="projectbrief">C.ONE Studio Damiao Development Board Framework</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.14.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search',true);
  $(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(function(){initNavTree('dji__motor_8h.html','',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div class="header">
  <div class="headertitle"><div class="title">dji_motor.h File Reference</div></div>
</div><!--header-->
<div class="contents">

<p>DJI智能电机头文件  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;bsp_can.h&quot;</code><br />
<code>#include &quot;<a class="el" href="controller_8h_source.html">controller.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="motor__def_8h_source.html">motor_def.h</a>&quot;</code><br />
<code>#include &quot;stdint.h&quot;</code><br />
<code>#include &quot;daemon.h&quot;</code><br />
</div>
<p><a href="dji__motor_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-nested-classes" class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:DJI_5FMotor_5FMeasure_5Fs" id="r_DJI_5FMotor_5FMeasure_5Fs"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_d_j_i___motor___measure__s.html">DJI_Motor_Measure_s</a></td></tr>
<tr class="memitem:DJIMotorInstance" id="r_DJIMotorInstance"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">DJI intelligent motor typedef.  <a href="struct_d_j_i_motor_instance.html#details">More...</a><br /></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-define-members" class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ab915b1993f2ebada9197d1c91cd93975" id="r_ab915b1993f2ebada9197d1c91cd93975"><td class="memItemLeft" align="right" valign="top"><a id="ab915b1993f2ebada9197d1c91cd93975" name="ab915b1993f2ebada9197d1c91cd93975"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>DJI_MOTOR_CNT</b>&#160;&#160;&#160;12</td></tr>
<tr class="memitem:a90084360b2511ca782b9678afc9bc12d" id="r_a90084360b2511ca782b9678afc9bc12d"><td class="memItemLeft" align="right" valign="top"><a id="a90084360b2511ca782b9678afc9bc12d" name="a90084360b2511ca782b9678afc9bc12d"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>SPEED_SMOOTH_COEF</b>&#160;&#160;&#160;0.85f</td></tr>
<tr class="memitem:a33cdc99b8eade9b0152839f6066effa6" id="r_a33cdc99b8eade9b0152839f6066effa6"><td class="memItemLeft" align="right" valign="top"><a id="a33cdc99b8eade9b0152839f6066effa6" name="a33cdc99b8eade9b0152839f6066effa6"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>CURRENT_SMOOTH_COEF</b>&#160;&#160;&#160;0.9f</td></tr>
<tr class="memitem:a229ef24e35ce08a9a817f66d67f7b155" id="r_a229ef24e35ce08a9a817f66d67f7b155"><td class="memItemLeft" align="right" valign="top"><a id="a229ef24e35ce08a9a817f66d67f7b155" name="a229ef24e35ce08a9a817f66d67f7b155"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>ECD_ANGLE_COEF_DJI</b>&#160;&#160;&#160;0.043945f</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-func-members" class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ae6a2dbd0d46fc7d80c6e2339aad09969" id="r_ae6a2dbd0d46fc7d80c6e2339aad09969"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ae6a2dbd0d46fc7d80c6e2339aad09969">DJIMotorInit</a> (<a class="el" href="struct_motor___init___config__s.html">Motor_Init_Config_s</a> *config)</td></tr>
<tr class="memdesc:ae6a2dbd0d46fc7d80c6e2339aad09969"><td class="mdescLeft">&#160;</td><td class="mdescRight">调用此函数注册一个DJI智能电机,需要传递较多的初始化参数,请在application初始化的时候调用此函数 推荐传参时像标准库一样构造initStructure然后传入此函数. recommend: type xxxinitStructure = {.member1=xx, .member2=xx, ....}; 请注意不要在一条总线上挂载过多的电机(超过6个),若一定要这么做,请降低每个电机的反馈频率(设为500Hz), 并减小DJIMotorControl()任务的运行频率.  <br /></td></tr>
<tr class="memitem:afc682af85b4e84a7a74d01097cf738e5" id="r_afc682af85b4e84a7a74d01097cf738e5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#afc682af85b4e84a7a74d01097cf738e5">DJIMotorSetRef</a> (<a class="el" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *motor, float ref)</td></tr>
<tr class="memdesc:afc682af85b4e84a7a74d01097cf738e5"><td class="mdescLeft">&#160;</td><td class="mdescRight">被application层的应用调用,给电机设定参考值. 对于应用,可以将电机视为传递函数为1的设备,不需要关心底层的闭环  <br /></td></tr>
<tr class="memitem:af949d3574538d826035110bf7e05c2f8" id="r_af949d3574538d826035110bf7e05c2f8"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#af949d3574538d826035110bf7e05c2f8">DJIMotorChangeFeed</a> (<a class="el" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *motor, <a class="el" href="motor__def_8h.html#a306d656c63a2d986e7aff57a0526395d">Closeloop_Type_e</a> loop, Feedback_Source_e type)</td></tr>
<tr class="memdesc:af949d3574538d826035110bf7e05c2f8"><td class="mdescLeft">&#160;</td><td class="mdescRight">切换反馈的目标来源,如将角速度和角度的来源换为IMU(小陀螺模式常用)  <br /></td></tr>
<tr class="memitem:a550e8d4dd6e722e66552563550191c65" id="r_a550e8d4dd6e722e66552563550191c65"><td class="memItemLeft" align="right" valign="top"><a id="a550e8d4dd6e722e66552563550191c65" name="a550e8d4dd6e722e66552563550191c65"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>DJIMotorControl</b> ()</td></tr>
<tr class="memdesc:a550e8d4dd6e722e66552563550191c65"><td class="mdescLeft">&#160;</td><td class="mdescRight">该函数被motor_task调用运行在rtos上,motor_stask内通过osDelay()确定控制频率 <br /></td></tr>
<tr class="memitem:a51d98dd3aee5e6e9530db1eb31f43642" id="r_a51d98dd3aee5e6e9530db1eb31f43642"><td class="memItemLeft" align="right" valign="top"><a id="a51d98dd3aee5e6e9530db1eb31f43642" name="a51d98dd3aee5e6e9530db1eb31f43642"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>DJIMotorStop</b> (<a class="el" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *motor)</td></tr>
<tr class="memdesc:a51d98dd3aee5e6e9530db1eb31f43642"><td class="mdescLeft">&#160;</td><td class="mdescRight">停止电机,注意不是将设定值设为零,而是直接给电机发送的电流值置零 <br /></td></tr>
<tr class="memitem:a7488031c4d093a41e2eaf8dd3881365b" id="r_a7488031c4d093a41e2eaf8dd3881365b"><td class="memItemLeft" align="right" valign="top"><a id="a7488031c4d093a41e2eaf8dd3881365b" name="a7488031c4d093a41e2eaf8dd3881365b"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>DJIMotorEnable</b> (<a class="el" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *motor)</td></tr>
<tr class="memdesc:a7488031c4d093a41e2eaf8dd3881365b"><td class="mdescLeft">&#160;</td><td class="mdescRight">启动电机,此时电机会响应设定值 初始化时不需要此函数,因为stop_flag的默认值为0 <br /></td></tr>
<tr class="memitem:adbffe8a35fe1da0ed6c36227ce30f1cd" id="r_adbffe8a35fe1da0ed6c36227ce30f1cd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#adbffe8a35fe1da0ed6c36227ce30f1cd">DJIMotorOuterLoop</a> (<a class="el" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *motor, <a class="el" href="motor__def_8h.html#a306d656c63a2d986e7aff57a0526395d">Closeloop_Type_e</a> outer_loop)</td></tr>
<tr class="memdesc:adbffe8a35fe1da0ed6c36227ce30f1cd"><td class="mdescLeft">&#160;</td><td class="mdescRight">修改电机闭环目标(外层闭环)  <br /></td></tr>
</table>
<a name="details" id="details"></a><h2 id="header-details" class="groupheader">Detailed Description</h2>
<div class="textblock"><p>DJI智能电机头文件 </p>
<dl class="section author"><dt>Author</dt><dd>neozng </dd></dl>
<dl class="section version"><dt>Version</dt><dd>0.2 </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2022-11-01</dd></dl>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000010">Todo</a></b></dt><dd><ol type="1">
<li>给不同的电机设置不同的低通滤波器惯性系数而不是统一使用宏<ol type="a">
<li>为M2006和M3508增加开环的零位校准函数,并在初始化时调用(根据用户配置决定是否调用)</li>
</ol>
</li>
</ol>
</dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>Copyright (c) 2022 HNU YueLu EC all rights reserved</dd></dl>
<dl class="section author"><dt>Author</dt><dd>neozng </dd></dl>
<dl class="section version"><dt>Version</dt><dd>0.2 </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2022-11-01</dd></dl>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000012">Todo</a></b></dt><dd><ol type="1">
<li>给不同的电机设置不同的低通滤波器惯性系数而不是统一使用宏<ol type="a">
<li>为M2006和M3508增加开环的零位校准函数,并在初始化时调用(根据用户配置决定是否调用)</li>
</ol>
</li>
</ol>
</dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>Copyright (c) 2022 HNU YueLu EC all rights reserved </dd></dl>
</div><a name="doc-func-members" id="doc-func-members"></a><h2 id="header-doc-func-members" class="groupheader">Function Documentation</h2>
<a id="af949d3574538d826035110bf7e05c2f8" name="af949d3574538d826035110bf7e05c2f8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af949d3574538d826035110bf7e05c2f8">&#9670;&#160;</a></span>DJIMotorChangeFeed()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void DJIMotorChangeFeed </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *</td>          <td class="paramname"><span class="paramname"><em>motor</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="motor__def_8h.html#a306d656c63a2d986e7aff57a0526395d">Closeloop_Type_e</a></td>          <td class="paramname"><span class="paramname"><em>loop</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Feedback_Source_e</td>          <td class="paramname"><span class="paramname"><em>type</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>切换反馈的目标来源,如将角速度和角度的来源换为IMU(小陀螺模式常用) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">motor</td><td>要切换反馈数据来源的电机 </td></tr>
    <tr><td class="paramname">loop</td><td>要切换反馈数据来源的控制闭环 </td></tr>
    <tr><td class="paramname">type</td><td>目标反馈模式 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ae6a2dbd0d46fc7d80c6e2339aad09969" name="ae6a2dbd0d46fc7d80c6e2339aad09969"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae6a2dbd0d46fc7d80c6e2339aad09969">&#9670;&#160;</a></span>DJIMotorInit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> * DJIMotorInit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_motor___init___config__s.html">Motor_Init_Config_s</a> *</td>          <td class="paramname"><span class="paramname"><em>config</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>调用此函数注册一个DJI智能电机,需要传递较多的初始化参数,请在application初始化的时候调用此函数 推荐传参时像标准库一样构造initStructure然后传入此函数. recommend: type xxxinitStructure = {.member1=xx, .member2=xx, ....}; 请注意不要在一条总线上挂载过多的电机(超过6个),若一定要这么做,请降低每个电机的反馈频率(设为500Hz), 并减小DJIMotorControl()任务的运行频率. </p>
<dl class="section attention"><dt>Attention</dt><dd>M3508和M2006的反馈报文都是0x200+id,而GM6020的反馈是0x204+id,请注意前两者和后者的id不要冲突. 如果产生冲突,在初始化电机的时候会进入IDcrash_Handler(),可以通过debug来判断是否出现冲突.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">config</td><td>电机初始化结构体,包含了电机控制设置,电机PID参数设置,电机类型以及电机挂载的CAN设置</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>DJIMotorInstance* </dd></dl>

</div>
</div>
<a id="adbffe8a35fe1da0ed6c36227ce30f1cd" name="adbffe8a35fe1da0ed6c36227ce30f1cd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adbffe8a35fe1da0ed6c36227ce30f1cd">&#9670;&#160;</a></span>DJIMotorOuterLoop()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void DJIMotorOuterLoop </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *</td>          <td class="paramname"><span class="paramname"><em>motor</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="motor__def_8h.html#a306d656c63a2d986e7aff57a0526395d">Closeloop_Type_e</a></td>          <td class="paramname"><span class="paramname"><em>outer_loop</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>修改电机闭环目标(外层闭环) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">motor</td><td>要修改的电机实例指针 </td></tr>
    <tr><td class="paramname">outer_loop</td><td>外层闭环类型 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="afc682af85b4e84a7a74d01097cf738e5" name="afc682af85b4e84a7a74d01097cf738e5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afc682af85b4e84a7a74d01097cf738e5">&#9670;&#160;</a></span>DJIMotorSetRef()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void DJIMotorSetRef </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *</td>          <td class="paramname"><span class="paramname"><em>motor</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float</td>          <td class="paramname"><span class="paramname"><em>ref</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>被application层的应用调用,给电机设定参考值. 对于应用,可以将电机视为传递函数为1的设备,不需要关心底层的闭环 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">motor</td><td>要设置的电机 </td></tr>
    <tr><td class="paramname">ref</td><td>设定参考值 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="page-nav" class="page-nav-panel">
<div id="page-nav-resize-handle"></div>
<div id="page-nav-tree">
<div id="page-nav-contents">
</div><!-- page-nav-contents -->
</div><!-- page-nav-tree -->
</div><!-- page-nav -->
</div><!-- container -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a href="dir_e05d7e2b1ecd646af5bb94391405f3b5.html">modules</a></li><li class="navelem"><a href="dir_e1337f9400e8caa7f7e380800549fa55.html">motor</a></li><li class="navelem"><a href="dir_f89843c4372d768f2c54a2320c5ec8ec.html">DJImotor</a></li><li class="navelem"><a href="dji__motor_8h.html">dji_motor.h</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li>
  </ul>
</div>
</body>
</html>
